/*
  ** LongStringDemo **
  Print a long Vietnamese text (UTF-8, NFC normalized) to LCD1602
  (generic ROM type or any ROM) via I2C (PCF8574)
  Author: Loc P. Le <phuocloc@gmail.com>

  ** Class **
  - LCDI2C_Vietnamese (LCDI2C_Generic_Vietnamese): for printing
    Vietnamese to LCDs with generic ROM (Japanese ROM or any other ROM)
    using customized characters created in CGRAM.
  - Max 8 Vietnamese letters with diacritics printed on a screen, otherwise diacritics removed.
  - Not for Arduino series due to memory limit.
  - If no longer room to print the next word in current line, it'll be printed in next line.
  - print(text, nsec): print long text with pause 'nsec' seconds
    If the screen is full, wait 'nsec' seconds for audience to read before printing the next part on next screen.

  ** Help **
  https://github.com/locple/LCDI2C_Multilingual
*/
#include <LCDI2C_Multilingual.h>
LCDI2C_Vietnamese lcd(0x27, 16, 2); // I2C address: 0x27; Display size: 16x2
// LCDI2C_Generic_Vietnamese lcd(0x27, 16, 2); // Another name of LCDI2C_Vietnamese class

void init1602()
{
  lcd.init();
  // lcd.backlight();
  lcd.println("Mppt");
}

int xh = 0;
unsigned long ShuxinTick = 0; // 心跳

void qidong1602()
{
  if (millis() - ShuxinTick >= 1000)
  {
    xh++;
    if (xh < 5)
    {
      lcd.print("Xdc");
      lcd.setCursor(9, 0);
      lcd.print("T:");
      lcd.print(MOS_T);
      lcd.setCursor(0, 1);
      lcd.print("U:");
      lcd.print(xdc_U / 1000);
      lcd.setCursor(9, 1);
      lcd.print("I:");
      lcd.print(xdc_I / 1000);
    }
    if (xh > 5)
    {
      lcd.print("Tyn");
      lcd.setCursor(9, 0);
      lcd.print("P:");
      lcd.print(tyn_P);
      lcd.setCursor(0, 1);
      lcd.print("U:");
      lcd.print(tyn_U / 1000);
      lcd.setCursor(9, 1);
      lcd.print("I:");
      lcd.print(tyn_I / 1000);

      // lcd.print("P:");
      // lcd.print(tyn_P);
      // lcd.println("W");
    }
    if (xh == 9)
    {
      xh = 0;
    }
    ShuxinTick = millis();
  }
}